<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>身份信息解析</title>
    <!--必要样式-->
    <style type="text/css">
        body {
            background-color: #f4f4f9;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        input[type="text"] {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            width: 100%;
            height: -webkit-calc(3em + 2px);
            height: calc(3em + 2px);
            margin: 0 0 1em;
            padding: 1em;
            border: 1px solid #cccccc;
            border-radius: 1.5em;
            background: #fff;
            resize: none;
            outline: none;
            transition: border-color 0.3s ease;
        }

        input[type="text"][required]:focus {
            border-color: #00bafa;
        }

        input[type="text"][required]:focus + label[placeholder]:before {
            color: #00bafa;
        }

        input[type="text"][required]:focus + label[placeholder]:before,
        input[type="text"][required]:valid + label[placeholder]:before {
            -webkit-transition-duration: .2s;
            transition-duration: .2s;
            -webkit-transform: translate(0, -1.5em) scale(0.9, 0.9);
            -ms-transform: translate(0, -1.5em) scale(0.9, 0.9);
            transform: translate(0, -1.5em) scale(0.9, 0.9);
        }

        input[type="text"][required]:invalid + label[placeholder][alt]:before {
            content: attr(alt);
        }

        input[type="text"][required] + label[placeholder] {
            display: block;
            pointer-events: none;
            line-height: 2.3em;
            margin-top: -webkit-calc(-3em - 2px);
            margin-top: calc(-3em - 2px);
            margin-bottom: -webkit-calc((3em - 1em) + 2px);
            margin-bottom: calc((3em - 1em) + 2px);
        }

        input[type="text"][required] + label[placeholder]:before {
            content: attr(placeholder);
            display: inline-block;
            margin: 0 -webkit-calc(1em + 2px);
            margin: 0 calc(1em + 2px);
            padding: 0 2px;
            color: #898989;
            white-space: nowrap;
            -webkit-transition: 0.3s ease-in-out;
            transition: 0.3s ease-in-out;
            background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff));
            background-image: -webkit-linear-gradient(top, #ffffff, #ffffff);
            background-image: linear-gradient(to bottom, #ffffff, #ffffff);
            -webkit-background-size: 100% 5px;
            background-size: 100% 5px;
            background-repeat: no-repeat;
            background-position: center;
        }

        input[type="button"] {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s ease;
        }

        input[type="button"]:hover {
            background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
        }

        /* 表格样式 */
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        }

        th,
        td {
            padding: 15px;
            text-align: center;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #f0f0f5;
            color: #333;
        }

        tr:hover {
            background-color: #f5f5f5;
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            border-radius: 10px;
            width: 300px;
            text-align: center;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div style="width:400px;height:100px;margin:300px auto">
        <form>
            <input id="idCard" name="idCard" required='' type='text'>
            <label alt='请输入身份证号' placeholder='身份证号'></label>
        </form>
        <table>
            <tbody>
                <tr>
                    <th><input type="button" value="获取身份证信息" /></th>
                </tr>
                <tr>
                    <td>
                        <div align="left"><font id="mAddress" size="2"></font></div>
                        <div align="left"><font id="mSex" size="2"></font></div>
                        <div align="left"><font id="mAge" size="2"></font></div>
                        <div align="left"><font id="mDate" size="2"></font></div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- 模态框 -->
    <div id="myModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <p id="modalMessage"></p>
        </div>
    </div>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/IDcard.min.js"></script>
    <script type="text/javascript" th:inline="javascript">
        $(document).ready(function () {
            // 获取模态框和关闭按钮
            var modal = $('#myModal');
            var span = $('.close');

            // 关闭模态框
            span.click(function () {
                modal.hide();
            });

            // 点击页面其他部分关闭模态框
            window.onclick = function (event) {
                if (event.target == modal[0]) {
                    modal.hide();
                }
            };

            $("#idCard").blur(function () {
                var idCard = $('#idCard').val();
                if (idCard) {
                    $('#mDate').html('出生日期：' + IdCard(idCard, 1));
                    $('#mSex').html('性别：' + IdCard(idCard, 2));
                    $('#mAge').html('年龄：' + IdCard(idCard, 3));
                    $('#mAddress').html('省份：' + id_card_area.getAreaByIdCard(idCard));
                } else {
                    $('#modalMessage').text('请输入身份证号！');
                    modal.show();
                }
            });
        });
    </script>
</body>

</html>    